import React from 'react';
import {withRouter} from "react-router-dom";
import "./style.css";


class Header extends React.Component {
  constructor(){
    super();
    this.state={
      backBtn:true
    }
  }
  componentDidMount(){
    const {backBtn}=this.props;
    if(backBtn===false){
      this.setState({backBtn:backBtn})
    }
  }
  browseShopping() {
    this.props.history.push("/home");
  }

  render() {
    const {title}=this.props;
    const {backBtn}=this.state;
    return (
      <div>
        <div className='header-box'>
          {backBtn?<div className='header-icon' onClick={this.browseShopping.bind(this)}>←</div>:''}
          <span>{title}</span>
        </div>
      </div>
    );
  }
}

export default withRouter(Header);
